package com.web.tag.bean;

import javax.servlet.http.HttpServletRequest;

public class PageModel {
	/**
	 * PAGE:添加request中的引用常量 count：静态变量，表示每个也面显示的数据条数 pageNum：表示当前在第几页
	 * recodeZong：这类数据的中条数
	 * countPage：同count静态变量一样，他有自己的setter/getter方法，表示每页显示的数据条数
	 * pageCount：表示总共有多少页 paths:表示连接页面的地址; pathAdd:在连接加入page参数之后继续追加。
	 */
	public static final String PAGEMODEL = "PAGEMODEL";
	public static final String PAGE = "page";
	public static final int count = 30;
	private int pageNum = 1, recodeZong, countPage = count;
	private String paths;
	private String pathAdd;
	private HttpServletRequest request;

	public PageModel() {
	}

	public PageModel(HttpServletRequest request) {
		this.request = request;
		this.paths = request.getRequestURL().append("?").toString();
	}

	public int getPageCount() {
		int pageCount = (recodeZong - 1) / countPage + 1;
		return pageCount;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
		this.paths = request.getRequestURL().append("?").toString();
	}

	public int getCountPage() {
		return countPage;
	}

	public void setCountPage(int countPage) {
		this.countPage = countPage;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		if (pageNum <= 0)
			pageNum = 1;
		this.pageNum = pageNum;
	}

	public int getRecodeZong() {
		return recodeZong;
	}

	public void setRecodeZong(int recodeZong) {
		this.recodeZong = recodeZong;
	}

	public String getPaths() {
		return paths;
	}

	public void setPaths(String paths) {
		this.paths = paths;
	}

	public String getPathAdd() {
		return pathAdd;
	}

	public void setPathAdd(String pathAdd) {
		this.pathAdd = pathAdd;
	}

	public HttpServletRequest getRequest() {
		return request;
	}
}
